<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 利用构造函数创建两个英雄对象。函数中的公共部分包括：姓名属性，类型属性(type)，血量属性(blood)，攻击方式(attack)
        // 廉颇：力量型  500血量  攻击：近战
        // 后羿：射手型  100血量  攻击：远程
        function Men(uname, type, blood) {
            this.uname = uname;
            this.type = type;
            this.blood = blood;
            this.attack = function(play) {
                console.log(play);
            }
        }
        var houyi = new Men('后羿', '射手型', 100);
        console.log(houyi.uname);
        console.log(houyi['type']);
        console.log(houyi.blood);
        houyi.attack('远程');

        var lianpo = new Men('廉颇', '力量型', 500);
        console.log(lianpo['uname']);
        console.log(lianpo.type);
        console.log(lianpo['blood']);
        lianpo.attack('近战');
    </script>
</head>

<body>

</body>

</html>